<?php
    //we should do the security task first!

$page_name=stripslashes($_POST["pagename"]);
$input=explode('#',stripslashes($_POST["layout"]));
$cols=array();
foreach($input as $i){
    $mod=array();
    $temp=explode('&',$i);
    foreach($temp as $t){
        if(!empty($t))
            $mod[]=explode('$',$t);
    }
    if(!empty($mod))
        $cols[]=$mod;
}

//then store the layout to database!
//FIXME: This part of code is coupled with the database config and
//project path. 
$r=serialize($cols);
include_once("../../../classes/PLFDao.php");
PLFDao::set("localhost","root","","plftest");
$c=new PLFDao();
$c->update("page_layout",array( 'page_layout' => serialize($cols) )
    ,"page_name='" . $page_name . "'");
$c->close();

    
?>
